<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@page import="dao.CommDAO" %>
<%@page import="util.Info" %>
<%@page import="util.PageManager" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>排班管理</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <LINK href="admin/css/admin.css" type="text/css" rel="stylesheet">
</head>
<body>
<form action="admin/pblist.jsp?f=f" method="post">
    <%
        CommDAO dao = new CommDAO();
        String did = request.getParameter("did");
        if (did != null) {
            dao.commOper("delete from schedule where id=" + did);
        }
        String sql = "SELECT sy.*, s.*, dept.deptname FROM schedule s " + "LEFT JOIN sysuser sy ON s.doctor_id = sy.id AND sy.utype = '医生' " + "LEFT JOIN dept ON dept.id = sy.dept " + "WHERE 1 = 1";
        String url = "/srykzsblmis/admin/schedulManage.jsp?1=1";
        String key = request.getParameter("key") == null ? "" : request.getParameter("key");
        String key1 = request.getParameter("key1") == null ? "" : request.getParameter("key1");
        String f = request.getParameter("f");
        if (f == null) {
            key = Info.getUTFStr(key);
        }
        if (!key.equals("")) {
            sql += " AND (sy.uname LIKE '%" + key + "%' OR sy.tname LIKE '%" + key + "%')";
            url += "&key=" + key;
        }
        if (!key1.equals("")) {
            sql += " AND (s.status = '" + key1 + "')";
            url += "&key1=" + key1;
        }
        sql += " ORDER BY s.shift_date asc, s.shift_date desc";
        PageManager pageManager = PageManager.getPage(url, 10, request);
        pageManager.doList(sql);
        PageManager bean = (PageManager) request.getAttribute("page");
        ArrayList<HashMap> nlist = (ArrayList) bean.getCollection();
    %>
    <TABLE cellSpacing=0 cellPadding=0 width="95%" align=center border=0>
        <TR height=20>
            <TD></TD>
        </TR>
        <TR height=22>
            <TD style="PADDING-LEFT: 20px; FONT-WEIGHT: bold; COLOR: #ffffff"
                align=middle background=admin/images/title_bg2.jpg>值班管理
            </TD>
        </TR>
        <TR bgColor=#ecf4fc height=12>
            <TD></TD>
        </TR>
        <TR height=20>
            <TD></TD>
        </TR>
    </TABLE>
    <TABLE cellSpacing=1 cellPadding=2 width="95%" align=center border=0 bgcolor="#cccccc">
        <th bgcolor="#ffffff" colspan="14">
            按姓名查询：<input type="text" id="key" name="key" value="<%= key %>"/>&nbsp;&nbsp;&nbsp;
            按状态查询：<select id="key1" name="key1">
            <option value="">全部</option>
            <option value="预约" <%= key1.equals("预约") ? "selected" : "" %>>预约</option>
            <option value="停诊" <%= key1.equals("停诊") ? "selected" : "" %>>停诊</option>
        </select>
            <input type="submit" value="查询"/>
        </th>
        <TR bgcolor="#ffffff" align="center">
            <TD>科室</TD>
            <TD>姓名</TD>
            <TD>性别</TD>
            <TD>电话</TD>
            <TD>用户类型</TD>
            <TD>值班日期</TD>
            <TD>值班时间</TD>
            <TD>状态</TD>
            <%
                HashMap admin = (HashMap) session.getAttribute("admin");
                if (admin.get("utype").equals("管理员")) {
            %>
            <TD>操作</TD>
            <%} %>
        </TR>
        <%
            for (HashMap mstu : nlist) {
        %>
        <tr bgcolor="#ffffff" align="center">
            <td><%= mstu.get("deptname") %>
            </td>
            <td><%= mstu.get("tname") %>
            </td>
            <td><%= mstu.get("sex") %>
            </td>
            <td><%= mstu.get("tel") %>
            </td>
            <td><%= mstu.get("utype") %>
            </td>
            <td><%= mstu.get("shift_date") %>
            </td>
            <td><%= mstu.get("shift_time") %>
            </td>
            <td>
                <%= "预约".equals(mstu.get("status")) ? "<font color='green'>可预约</font>" : "<font color='red'>已停诊</font>" %>
            </td>
            <%
                if (admin.get("utype").equals("管理员")) {
            %>
            <td>
                <a href="admin/pbedit.jsp?id=<%= mstu.get("id") %>">修改</a>
                &nbsp;&nbsp;|&nbsp;&nbsp;
                <a href="admin/pblist.jsp?did=<%= mstu.get("id") %>">删除</a>
            </td>
            <%} %>
        </tr>
        <%
            }
        %>
        <tr>
            <td colspan="14" align="center" bgcolor="#FFFFFF">${page.info} </td>
        </tr>
    </TABLE>

</form>
</body>
</html>

